<#include 'layout/template.ftl'/>
<@htmlHead title=''>
	<!-- page specific plugin styles -->
	<link rel="stylesheet" href="${resources}/assets/css/jquery-ui.css" />
	<link rel="stylesheet" href="${resources}/assets/css/datepicker.css" />
	<link rel="stylesheet" href="${resources}/assets/css/ui.jqgrid.css" />
	<link rel="stylesheet" href="${resources}/plugins/jqgrid/4.6/jqgrid.extend.css" />
</@htmlHead>


<@htmlBody 'floor'  'pcFloor'   >

	<#include 'layout/breadcrumbs.ftl'>
	<@breadcrumbs '管理'   '列表'></@breadcrumbs>

	<!-- page-content begin -->
	<div class="page-content">
			
			<!-- page-header begin -->
			<div class="page-header">
					<h1>
						列表
					</h1>
			</div>
			<!-- page-header end -->


			<div class="row">
				<div class="col-md-12">	
					<div id="opt"> 
					    <div id="query"> 
				       		<label>名称：</label><input type="text" class="input-sm" id="name" /> 
				            <input type="submit" class="btn btn-sm btn-primary" id="find_btn" value="查 询" /> 
					       <a href="${path}/manage/floor/pcFloor/create" class="btn btn-sm btn-primary">新增</a>
					    </div>
					</div> 
				</div>	
			</div>
			
			<!-- form begin -->
			<div class="row">	
				<div class="col-md-12">
					<!-- jqGrid begin -->
				  	<table id="grid-table"></table>
			 		<div id="grid-pager"></div>
			 		<!-- jqGrid end -->
	
				</div>
			</div>	
			<!-- form end -->
	</div>		
	<!-- page-content end -->	


</@htmlBody>

<@htmlBodyScript>

		<script src="${resources}/assets/js/date-time/bootstrap-datepicker.js"></script>
		<script src="${resources}/assets/js/jqGrid/jquery.jqGrid.src.js"></script>
		<script src="${resources}/assets/js/jqGrid/i18n/grid.locale-cn.js"></script>

		<script>
			var $path ='${path}';
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";
			
			//价格
         	function formatPrice(cellValue, options, rowObject) {
         		return accounting.formatMoney(cellValue, "¥", 2, ",", ".");
    		}
    		//数量
         	function formatNumber(cellValue, options, rowObject) {
         		return accounting.formatNumber(cellValue);
    		}
    		//时间
			function formatDatetime(cellValue, options, rowObject) {
				var output = moment(cellValue).format('YYYY-MM-DD');
				return output;
			}
			//状态
			function formatStatus(cellValue, options, rowObject) {
         		var option = '<div class="ui-status">';
				if(cellValue==1){
					option+= "<span class='label label-sm label-success'>正常</span>";
				}
				else if(cellValue==2){
					option+= "<span class='label label-sm label-danger'>停用</span>";
				}
				option = option +'</div>';      
           		return option;
    		}
				
			$(function(){
				//分页插件开始
				$("#grid-table").jqGrid({
					url: '${path}/manage/floor/pcFloor/list',
				 	mtype : "post", 
					datatype: "json",
					cellEdit:true,
					async:false,
					cellurl:'${path}/manage/floor/pcFloor/updatesort',
					cellsubmit:'remote',
					colNames:[	'id','标题','排序','状态','创建人','创建时间','操作'],
				 	colModel: [
						{name:'id', width:100},
						{name:'name', width:100},
						{name:'sortno',index:'sortno',editable:true,editrules:{number:true}},
						{name:'status', width:100,formatter:formatStatus},
						{name:'creator', width:100},
						{name:'createTime', width:100,formatter:formatDatetime},

						{
							name:'id', 
							width:150,
							formatter:function(cellvalue, options, rawObject) {
								var option = '<div class="ui-op">';
								option = option +'<a href="${path}/manage/floor/pcFloor/update/'+cellvalue+'">编辑'; 
						        option = option +'</a>';
								option = option +'<a href="${path}/manage/floor/pcFloor/delete/'+cellvalue+'"  onclick=\'return confirm("是否删除?");\'>删除';
						        option = option +'</a>';
						        option = option +'</div>';      
						   		return option;  
							}
						}
					
					],
					viewrecords: true, 							// 在toolbar显示的当前页数,步长,总数
					autowidth: true,								//自动宽度
					height: 350,
					rowNum: 10,
					rowList:[10,20,30],
					sortname: 'id',
					sortorder: 'asc',
					pager: "#grid-pager",
					caption: "列表",
					loadComplete : function() {
						var table = this;
						setTimeout(function(){
							styleCheckbox(table);
							updateActionIcons(table);
							updatePagerIcons(table);
							enableTooltips(table);
						}, 0);
					},
					afterSubmitCell:function (serverresponse, rowid, cellname, value, iRow, iCol){
						//转换json
						var result=serverresponse.responseText;
						var json = eval('(' + result + ')');
						if(json.code==500){
							_letsun_show_msg("ok","修改成功",2000);
						}else{
							_letsun_show_msg("war","修改失败",2000);
						}
						//重新刷新列表
						$("#grid-table").jqGrid('clearGridData');
						$("#grid-table").jqGrid('setGridParam',{
						      url:"${path}/manage/floor/pcFloor/list",
						      datatype:'json',
						}).trigger("reloadGrid");
					},
					viewrecords: true,
					subGrid:true,
					subGridRowExpanded: function(subgrid_id, row_id) {	
						//(2)子表格容器的id和需要展开子表格的行id，将传入此事件函数  
						            var subgrid_table_id;  
						            subgrid_table_id = subgrid_id + "_t"; 
						            //(3)根据subgrid_id定义对应的子表格的table的id  
						            var subgrid_pager_id;  
						            subgrid_pager_id = subgrid_id + "_pgr"  
						            //(4)根据subgrid_id定义对应的子表格的pager的id  
						            // (5)动态添加子报表的table和pager  
						            $("#" + subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'>"+
						            "</table><div id='"+subgrid_pager_id+"'class='scroll'></div>");  
						            // (6)创建jqGrid对象  
						            $("#" + subgrid_table_id).jqGrid({  
						                url: "${path}/manage/floor/pcFloor/floorInfo/"+row_id,  
						                //(7)子表格数据对应的url，注意传入的contact.id参数  
						                datatype: "json",  
						            	mtype : "post", 
						            	cellEdit:true,
										async:false,
										cellurl:'${path}/manage/bank/category/updatesort',
						                colNames:[ 'ID','标题','链接','logo'],
									 	colModel: [
											{name:'id',index:'id', width:70},
											{name:'name',index:'name',width:400},
											{name:'linkurl',index:'linkurl',width:300},
											{name:'picurl',index:'picurl',width:300,
												formatter:function(cellvalue, options, rawObject) {
													var option = '<div style="width:100px; height:100px;"><img src ='+cellvalue+'></div>';    
											   		return option;  
												}
											}
										],  
						               /*  jsonReader: {   // (8)针对子表格的jsonReader设置  
						                    root:"gridModel",  
						                    records: "record",  
						                    repeatitems : false  
						                },   */
						                //prmNames: {search: "search"},  
						                pager: subgrid_pager_id,  
						                viewrecords: true,  
						                height:10,  
						                rowNum: 5 ,
						            	caption: "子分类列表",
										loadComplete : function() {
											var table = this;
											setTimeout(function(){
												styleCheckbox(table);
												updateActionIcons(table);
												updatePagerIcons(table);
												enableTooltips(table);
											}, 0);
										}
						           });  
						       }  
				});
				//------------------------------- 自定义查询开始 -------------------------------
				//自定义查询开始
				$("#find_btn").click(function(){ 
					searchData('${path}/manage/floor/pcFloor/list');
			    }); 
				//自定义查询结束
				
			})
		</script>	
	    <script src="${resources}/assets/js/jqGrid/jquery.jqGrid.Extract.js"></script>
	    

</@htmlBodyScript>	


